Cracking the AP Computer Science a Exam, 2020 Edition by The Princeton Review

Cracking the AP Computer Science a Exam, 2020 Edition by The Princeton Review

Author:The Princeton Review
Language: eng
Format: epub
Publisher: Random House Children's Books
Published: 2020-01-13T16:00:00+00:00


Use the following incomplete class declarations to answer Questions 6 and 7.

public class Number

{

private int value;

public Number(int someNum)

{

if (someNum >= 0)

value = someNum;

}

public int changeVal(int newVal)

{

/ * missing code * /

}

public int getValue()

{

return value;

}

}

public class NumChanger

{

public void change()

{

Number n1 = new Number(5);

Number n2 = new Number(5);

int sum1 = n1.getValue() + n2.getValue();

int oldn1Val = n1.changeValue(10);

n2 = n1;

int sum2 = n1.getValue() + n2.getValue();

System.out.print(sum1 + “ ” + sum2);

}

//other methods not shown

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.